# -*- coding:utf-8 -*-
import unittest
import json
import urllib2


class TestStart(unittest.TestCase):
    def put_json(self, url, v):
        value = json.dumps(v)
        req = urllib2.Request(url, value, {'Content-Type': 'application/json'})

        response = urllib2.urlopen(req)

        return response.read()

    def check_put_json(self, url, data, ret):
        respone = self.put_json(url, data)

        d = json.loads(respone)
        self.assertEqual(d, ret)

    def scheme(self):
        url = "http://localhost/graphdb"

        self.check_put_json(url, {
            "cmd": "init"
            }, "Success")

        self.check_put_json(url, {
            "cmd": "reset"
            }, "Success")

    def test_real(self):
        self.scheme()


if __name__ == '__main__':
    unittest.main()
